const app = getApp()
// pages/index/result.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    words:[],
    gift:[],
    gifted:0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
   
  },



  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    that.getGift(app.globalData.openid);
    that.getWord(app.globalData.openid);
  },

  getWord:function(openid) {
    var that = this;
    var url = app.data.serverUrl + 'get-result';
    wx.request({
      url: url,
      data:{'openid':openid},
      success:function(res){
        if(res.data.status==true) {
          that.setData({
            words:res.data.data,
          })
        }
      }
    })
  },

  getGift: function (openid) {
    var that = this;
    var url = app.data.serverUrl + 'get-gift';
    wx.request({
      url: url,
      data: { 'openid': openid },
      success: function (res) {
        if (res.data.status == true) {
          that.setData({
            gift: res.data.data,
            gifted:1
          });
          wx.setStorageSync('gifted', true)
        }
      }
    })
  },

 
})